package trlygjj.tanruiliyigenjinjin.query;

import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import trlygjj.tanruiliyigenjinjin.util.DateUtil;
import trlygjj.tanruiliyigenjinjin.util.StringUtil;

import java.util.*;


/**
 * Created by user on 2018/7/7.
 */

/**
 * 查询条件的父类
 */
@Setter
@Getter
public class ChartQueryObject extends QueryObject {

    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date beginDate;
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date endDate;

    private String keyword;

    private String groupByType = "p.name";


    /*
    * 判断页面传入的关键字
    * */
    public String getKeyword() {
        return StringUtil.hasLength(keyword) ? keyword : null;
    }

    public Date getEndDate(){
        if(endDate!=null){
            return DateUtil.getEndDate(endDate);
        }
        return null;
    }

    public String getGroupByType(){
        if(groupByType == null && groupByType.trim().length() == 0){
            return "p.name";
        }
        return groupByType;
    }

    public static List<Map<String,String>> list = new ArrayList<>();
    public static Map<String,String> map = new LinkedHashMap<>();
    static {

        map.put("sn","p.name");
        map.put("text","正式学员");
        //map.put("grade.name","意向班级");
        list.add(map);
    }
}
